package com.scanner.hardware;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.scanner.bean.ScanSetting;
import com.scanner.util.BaseUtils;
import com.scanner.util.SharePreConfig;

public class WelcomeActivity extends Activity {

    private Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        mHandler.postDelayed(() -> {
            Intent intent = new Intent();

            if(SharePreConfig.getIsFirstOpen() ){
                ScanSetting settingFormShare = BaseUtils.getSettingFormShare();
                if(settingFormShare.getScanModule() >0 && settingFormShare.getScanModule() < 5){//已经设置了扫描模块
                    SharePreConfig.setIsFirstOpen(false);
                    intent.setClass(WelcomeActivity.this,StartActivity.class);
                }else {
                    intent.setClass(WelcomeActivity.this,ChooseScannerActivity.class);
                }
            }else {
                intent.setClass(WelcomeActivity.this,StartActivity.class);
            }
            startActivity(intent);
            finish();
        },1500);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mHandler != null)
        mHandler.removeCallbacksAndMessages(null);
    }
}
